class Solution
{
public:
    int findClosestNumber(vector<int> &nums)
    {
        int closest = INT_MAX;
        for (int num : nums)
        {
            if (abs(num) < abs(closest))
            {
                closest = num;
            }
            else if (abs(num) == abs(closest))
            {
                closest = max(closest, num);
            }
        }
        return closest;
    }
};